package com.lvmama.finance.demo.elasticsearch.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.lvmama.finance.demo.elasticsearch.sync.DataSyncManager;

@Configuration
@EnableScheduling
public class SchduleConfig {

	@Autowired
	private DataSyncManager dataSyncManager;
	
	@Scheduled(initialDelay = 1000 * 60, fixedDelay = 1000 * 60)
	public void triggerDataSync() {
		dataSyncManager.syncData();
	}
	
	@Scheduled(fixedDelay = 1000 * 30)
	public void triggerNodeCheck() {
		dataSyncManager.updateNodeStatus();
	}
}
